package com.mz.ozy.mvp.presenter;


import android.app.Activity;
import android.content.Context;

import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.bean.FriendBean;
import com.mz.ozy.bean.PronotionBean;
import com.mz.ozy.mvp.model.MeModel;
import com.mz.ozy.mvp.view.FriendContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import org.json.JSONObject;

import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class FriendPresenter extends BasePresenterImpl<FriendContract.View> implements FriendContract.Presenter {

    private MeModel mModel;


    public FriendPresenter() {
        mModel = new MeModel();
    }

    @Override
    public void getFriendInfo(Activity activity, String page) {
        mModel.getFriendInfo(activity, page)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<FriendBean>(mView) {
                    @Override
                    public void onSuccesss(FriendBean bean) {
                        mView.getFriendSuccess(bean);
                    }
                });
    }

    @Override
    public void vipUp(Context context, String certificate, String id, int type) {
        mModel.getVipUpJs(context, certificate, id, type)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<JSONObject>(mView) {
                    @Override
                    public void onSuccesss(JSONObject bean) {
                        mView.getVipUpSuccess(bean);
                    }
                });
    }

    @Override
    public void vipUpSh(Context context, int type) {
        mModel.getVipUpSh(context, type)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<FriendBean>(mView) {
                    @Override
                    public void onSuccesss(FriendBean bean) {
                        mView.getVipUpShSuccess(bean);
                    }
                });
    }

    @Override
    public void vipUpDataSh(Context context, String id, int type) {
        mModel.getVipUpDataInfo(context, id, type)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<PronotionBean>(mView) {
                    @Override
                    public void onSuccesss(PronotionBean bean) {
                        mView.getVipUpDataInfoSuccess(bean);
                    }
                });
    }
}
